<?php

namespace App\Http\Controllers\Estate;

use App\Http\Controllers\Controller;
use App\Http\Resources\Estate\PlaformOwnerResource\PlaformOwnerCollection;
use App\Models\AdminEstate;
use App\Models\PaymentOrder;
use App\Services\UserService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;

class PaymentOrderController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {

        $data=$request->query();
        $where = [];
        if (isset($data['orderNo']))
        {
            $where[] = ['orderNo', 'like' ,"%{$data['orderNo']}%"];
        }
        if (isset($data['pay_no']))
        {
            $where[] = ['pay_no',  'like' ,"%{$data['pay_no']}%"];
        }
        if (isset($data['status']))
        {
            $where['status'] = $data['status'];
        }
        $list = PaymentOrder::query()
            ->with(['community_owner',"platform_agent"])
            ->where($where)
            ->orderBy('id', 'desc')
            ->paginate($request->per_page ?? 30);
//        return $this->success($list);
        return $this->success($list);
    }


}
